<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script type="text/JavaScript">
	var grid,windowparam=0;
	$(function() {
		//分类管理表格  
		grid = $('#linkgrid').datagrid({
	    url:'listLink.do',  
	    loadMsg:'数据加载中请稍后……',  
	    pagination: true,  
	    rownumbers: true, 
        striped: true,  
        singleSelect : true,  
        pageSize: [${syscfg.pageSize!10}],
        pageList: [${syscfg.pageList!10}],
       columns:[[  
             {field:'id',title: 'ID',align: 'center',width: '50'},  
             {field:'linktypeName',title: '类型',align: 'center',width: '100'},
             {field:'webname',title: '网站名称',align: 'center',width: '200'},
             {field:'webmaster',title: '站长',align: 'center',width: '200'},
             {field:'email',title: '邮箱',align: 'center',width: '200'},
             {field:'pass',title: '状态',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
					if(value == 0){
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:cancleLink('+rowdata.id+','+rowdata.pass+')""><span class="l-btn-left"><span class="l-btn-text icon-no l-btn-icon-left">启用</span></span></a>';
					}else{
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:cancleLink('+rowdata.id+','+rowdata.pass+')""><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">禁用</span></span></a>';
					}
					return str;
				}
             }]],
             toolbar : [btn_add, btn_edit, btn_del ,"-"]
     });
		//
		$("#tree").tree({
		    method: "post",
		    lines: true,
		    url: "listLinktypeForTree.do",
		    dataPlain: true,       //该属性用以启用当前 easyui-tree 控件对平滑数据格式的支持
		    toggleOnClick: false,
		    enableContextMenu: false,
		    onClick: function(node){
		        var params = {};
		        windowparam = node.id;
				params['linktype'] = node.id;
				grid.datagrid('reload',params); 
			}
		});
  })
    //新增
	function doAdd() {
		var url = '${request.contextPath}/xadmin/added/linkWindow.do?linktype='+windowparam;
		top.modalwindow(url , grid,{width:500, height:400, title:'新增链接信息'});
	}	
	//修改
	function doEdit() {
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		//
		var url = '${request.contextPath}/xadmin/added/linkWindow.do?id='+selected.id+'&linktype='+windowparam;
		top.modalwindow(url, grid,{ width:500,height:400,title:'修改投票信息',});
	}
	//删除
	function doDel(){
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("delLink.do", { "id": selected.id},
				   function(data){
				   	grid.datagrid('reload'); 
				   	top.messagershow(data);				   	
				});
			}
		});
	}
	function cancleLink(id,result){
		if(result==0){
			result =1;
		}else{
			result = 0;
		}
		$.post("checkLink.do", { "id": id,"result":result},
		   	function(data){
		   		grid.datagrid('reload'); 
		   		top.messagershow(data);
		});
	}
</script>

</head>
<body class="easyui-layout">
<div data-options="region:'west',iconCls:'icon-mini-add',title:'按类型查找',split:true" style="width:180px;">
	<div class="easyui-panel" data-options='fit:true,border:false'> 
		<ul id="tree"></ul>
	</div>
</div>   
<div data-options="region:'center'">
<table id="linkgrid" data-options="fit:true,border:false"></table>
</div>  
</body>
</html>